package org.vectrics.recruiter.user.Test;

import junit.framework.TestCase;
import org.apache.log4j.Category;

/**
 * Title:        Common files for Vectrics Web
 * Description:
 * Copyright:    Copyright (c) 2001
 * Company:      Vectrics
 * @author Mike Moore
 * @version 1.0
 */

public class TestUser extends TestCase {
    private static Category log = Category.getInstance(TestUser.class);

    public TestUser(String iName)
    {
        super(iName);
    };

    public void testSkill()
    {
        /*
        SkillSet allSkills = new SkillSet();
        Skill.setMasterSkillSet(allSkills);

        Skill skill1 = new Skill();
        skill1.setDescription("Skill 1");
        skill1.setSkillCode("skill_1");
        skill1.setParentCode("root");
        allSkills.add(skill1);

        Iterator iter = allSkills.getRootSkill().getChildren().iterator();
        Skill testSkill = (Skill)iter.next();

        this.assertEquals(testSkill.getSkillCode(), "skill_1");



        Skill skill2 = new Skill();
        skill2.setDescription("Skill 2");
        skill2.setSkillCode("skill_2");
        skill2.setParentCode("root");
        allSkills.add(skill2);


        Skill skill_1_1 = new Skill();
        skill_1_1.setDescription("Skill 1.1");
        skill_1_1.setSkillCode("skill_1_1");
        skill_1_1.setParentCode("skill_1");
        skill_1_1.setNeedsYesNo(true);
        skill_1_1.setNeedsYears(true);
        skill_1_1.setNeedsLevel(true);
        allSkills.add(skill_1_1);

        Skill skill_1_2 = new Skill();
        skill_1_2.setDescription("Skill 1.2");
        skill_1_2.setSkillCode("skill_1_2");
        skill_1_2.setParentCode("skill_1");
        skill_1_2.setNeedsYesNo(true);
        skill_1_2.setNeedsYears(true);
        skill_1_2.setNeedsLevel(true);
        allSkills.add(skill_1_2);


        Skill skill_1_3 = new Skill();
        skill_1_3.setDescription("Skill 1.3");
        skill_1_3.setSkillCode("skill_1_3");
        skill_1_3.setParentCode("skill_1");
        skill_1_3.setNeedsYesNo(true);
        skill_1_3.setNeedsYears(true);
        skill_1_3.setNeedsLevel(true);
        allSkills.add(skill_1_3);

        User user = new User();
        user.setUserName("test_user");

        UserSkillSet userSkillSet = new UserSkillSet();
        userSkillSet.setUser(user);
        assertEquals(user.getUserName(), userSkillSet.getUser().getUserName());

        SkillRating rating1 = new SkillRating();
        rating1.setSkill(skill_1_2);
        userSkillSet.addSkillRating(rating1);

        this.assertTrue(userSkillSet.getUserHasParentSkill(skill1));
        this.assertEquals(userSkillSet.getUserHasParentSkill(skill2), false);

        SkillRating rating2 = new SkillRating();
        rating2.setSkill(skill2);
        rating2.setLevel(Skill.intermediate);
        rating2.setYears(3);
        this.assertEquals(3, rating2.getYears());
        log.debug("Before rating 2 : " + userSkillSet.toString());
        userSkillSet.addSkillRating(rating2);
        log.debug("After rating 2 : " + userSkillSet.toString());
        this.assertEquals(3, rating2.getYears());

        this.assertEquals(skill2.getSkillCode(), userSkillSet.getSkillRating(skill2).getSkill().getSkillCode());
        this.assertEquals(rating2, userSkillSet.getSkillRating(skill2));
        this.assertEquals(userSkillSet.getSkillRating(skill2).getSkill(), skill2);
        this.assertEquals(3, userSkillSet.getSkillRating(skill2).getYears());
        this.assertEquals(Skill.intermediate, userSkillSet.getSkillRating(skill2).getLevel());
        this.assertTrue(userSkillSet.getUserHasParentSkill(skill1));
        this.assertTrue(userSkillSet.getUserHasParentSkill(skill2));

        // Test UserSkillSet.clearSkillBranch()
        userSkillSet.clearSkillBranch(skill1);
        this.assertEquals(userSkillSet.getSkillRating(skill_1_2), null);

        userSkillSet.clearSkillBranch(allSkills.getRootSkill());
        log.debug(userSkillSet.toString());
        this.assertEquals(0, userSkillSet.size());


        // Test clearUnrated()
        rating2 = new SkillRating();
        rating2.setSkill(skill2);
        rating2.setLevel(Skill.none);
        rating2.setYears(0);
        userSkillSet.addSkillRating(rating2);

        assertTrue(userSkillSet.getSkillRating(skill2) == rating2);
        userSkillSet.clearUnrated();
        assertTrue(userSkillSet.getSkillRating(skill2) == null);
*/
    };


}